<!--
/**************************************************
* @(#)accountview.jsp
*
* Copyright (c) 2005 Hitrust Technology Inc.
* Developed by SDC, Hitrust.
* All Rights Reserved.
*
* Modify History:
*  v1.00, 2006/05/10, owen
*  1) first release
/**************************************************
-->
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ include file="../../common.jsp" %>
<%@ taglib uri="/page.util.gs.hitrust.com/taglibs/page" prefix="page"%>
<%
	ResultProcess tAccountlist = (ResultProcess)request.getAttribute("accountlist");
	ArrayList tList = new ArrayList();
	String [] tStr = null;
	String tReQuery = (String)request.getAttribute("requery");
	
%>

<html>
   <head>
		<title>本月对帐浏览</title>
	<META http-equiv=Content-Type content="text/html; charset=UTF-8">
    <LINK href="<%=root%>/css/caigouxitong.css" type=text/css rel=stylesheet>
    <SCRIPT language="JavaScript" src="<%=root%>/js/common.js"></SCRIPT>
    <SCRIPT language="JavaScript" src="<%=root%>/js/calendar.js"></SCRIPT>
    <script>
    function process()
    {
         var tStr = "";		
		 var tEnd = "";				
		 
		 if(!isEmpty(accountform.startdate.value))
		 {
			tStr = accountform.startdate.value.substr(0,4) + accountform.startdate.value.substr(5,2) + accountform.startdate.value.substr(8,2);
		 }
		 
		 if(!isEmpty(accountform.enddate.value))
		 {
			tEnd = accountform.enddate.value.substr(0,4) + accountform.enddate.value.substr(5,2) + accountform.enddate.value.substr(8,2);						
		 }
		 
		 if(parseInt(tStr) > parseInt(tEnd))
		 {
			alert("订单创建周期的开始日期不能大于截止日期！");
			return false;
		 }		
		 
		 if(isEmpty(accountform.year.value))
		 {
		 	alert("对帐年份不能为空！");
		 	accountform.year.focus();
		 	return false;
		 }

		 if(isEmpty(accountform.month.value))
		 {
		 	alert("对帐月份不能为空！");
		 	accountform.month.focus();
		 	return false;
		 }
		 			
		 accountform.action = "<%= response.encodeURL(request.getContextPath() + "/A210102.do") %>";
		 accountform.submit();
	 }
     function processT()
     {
	    <%
		    if(tReQuery!=null && tReQuery.equals("true")){
		%>
		   
		   accountform.action = "<%= response.encodeURL(request.getContextPath() + "/A210102.do") %>";
    	   accountform.submit();
           return true;
    	<%}%>
				  
	}

    function clean()
    {
      	accountform.orderDeptId.value="0000";
	    accountform.deliverGoodsId.value="";
	    accountform.providerid.value="";
	    accountform.concentricityId.value="";
	    accountform.manufInfo.value="";
	    accountform.year.value="";
	    accountform.month.value="";
	    accountform.startdate.value="";
	    accountform.enddate.value="";
    }
    
    function download()
    {
             var tStr = "";		
			 var tEnd = "";				
			 if(!isEmpty(accountform.startdate.value)){
				tStr = accountform.startdate.value.substr(0,4) + accountform.startdate.value.substr(5,2) + accountform.startdate.value.substr(8,2);
				 }
				if(!isEmpty(accountform.enddate.value)){
					tEnd = accountform.enddate.value.substr(0,4) + accountform.enddate.value.substr(5,2) + accountform.enddate.value.substr(8,2);						
					}
						if(parseInt(tStr) > parseInt(tEnd)){
								alert("订单创建周期的开始日期不能大于截止日期！");
								return false;
						}

var orderDeptId=accountform.orderDeptId.value;        							
var deliverGoodsId=accountform.deliverGoodsId.value;        							
var manufInfo=accountform.manufInfo.value;        							
var concentricityId=accountform.concentricityId.value;        							
var providerid=accountform.providerid.value;        							
var startdate=accountform.startdate.value;        							
var enddate=accountform.enddate.value;        							
var year=accountform.year.value;        							
var month=accountform.month.value;  
//alert(orderDeptId);      		      							
var url = '<%= response.encodeURL(request.getContextPath() + "/A210104.do") %>?orderDeptId='+orderDeptId+'&deliverGoodsId='+deliverGoodsId+'&manufInfo='+manufInfo+'&concentricityId='+concentricityId+'&providerid='+providerid+'&startdate='+startdate+'&enddate='+enddate+'&year='+year+'&month='+month;
window.open(url,null," edge: sunken ,center: Yes, help: No, resizable: Yes, status: No,width=180px,height=150px, scrollbars=yes")
		//accountform.action = "";
			    		//accountform.submit();
             }
    
    </script>

   </head>
	<body BGCOLOR="#f2f2f2" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload="processT()">
		
			<p><FONT face="宋体"></FONT><FONT face="宋体"></FONT><FONT face="宋体"></FONT><FONT face="宋体"></FONT><FONT face="宋体"></FONT><FONT face="宋体"></FONT><br>
			</p>
			<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
				<tr>
					<td height="20">
						<table width="100%" border="0" cellspacing="0" cellpadding="1">
							<tr height="20">
								<td height="20" width="1" class="mtxt_black">&nbsp;</td>
								<td height="30" width="758" class="mtxt_black">本月对帐浏览/下载</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td class="bg_line" height="2"></td>
				</tr>
			</table>
			<br>
			<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
				<TBODY>
					<tr>
						<td>
						<form name=accountform method="get">
							<table class="bg_table" id="tableId" cellspacing="1" cellpadding="0" style="PADDING-RIGHT:5px;PADDING-LEFT:5px"
									width="100%" align="center" border="0">
									
									<TR height="20">
										<TD class="bg_column" align="center" width="15%">订货单位</TD>
										<TD align="left" class="bg_row_odd" width="35%">
										<select name="orderDeptId">					
						                  <option value="0000" selected>---全部---</option>
			                              <%  
			                                HashMap tMap = (HashMap)request.getAttribute("orderdept");
			                                ArrayList tOrderDeptList = (ArrayList)tMap.get("organization");
				                            String tOrderDept = request.getParameter("orderDeptId");
				                            if(tOrderDeptList != null && tOrderDeptList.size() > 0 ){	
				                              if(tOrderDept != null && tOrderDept.equals("0000")){
						                         for(int i=0; i<tOrderDeptList.size(); i++){
						                           String[] temp = (String[])tOrderDeptList.get(i);
			                              %>
							             <option value="<%=temp[0]%>"><%=temp[1]%></option>						
			                          <%			    
									       }
							           }else{
									     for(int i=0; i<tOrderDeptList.size(); i++){
									          String[] temp = (String[])tOrderDeptList.get(i);
										      if(tOrderDept != null && tOrderDept.equals(temp[0])){
							                 %>
											<option value="<%=temp[0]%>" selected>
											<%=temp[1]%></option>
							<%				    
										}else{
							%>
											<option value="<%=temp[0]%>"><%=temp[1]%></option>
							<%			
										}
									}
							    }
							}

						%>
						</select>
										</TD>
										<TD class="bg_column" align="center" width="15%">送货单号</TD>
										<TD align="left" class="bg_row_odd" width="35%">
											<input type="text" name="deliverGoodsId" value="<%=request.getParameter("deliverGoodsId")==null?"":request.getParameter("deliverGoodsId")%>">
										</TD>
									</TR>
									<TR height="20">
										<TD class="bg_column" align="center">供应商</TD>
										<TD align="left" class="bg_row_odd">
										<input type="text" name="providerid" value="<%=request.getParameter("providerid")==null?"":request.getParameter("providerid")%>"></TD>
										<TD class="bg_column" align="center">集中编码</TD>
										<TD align="left" class="bg_row_odd">
										<input type="text" name="concentricityId" value="<%=request.getParameter("concentricityId")==null?"":request.getParameter("concentricityId")%>"></TD>
									</TR>
									<TR height="20">
										<TD class="bg_column" align="center">产品信息</TD>
										<TD align="left" class="bg_row_odd" colspan="3">
											<input type="text" name="manufInfo" value="<%=request.getParameter("manufInfo")==null?"":request.getParameter("manufInfo")%>">（<FONT color="#ff0033">对产品名称、型号、规格、品牌、生产厂商、附加属性等关键字的模糊查询</FONT>）
										</TD>
									</TR>
                                    <%
                                    SimpleDateFormat bartDateFormat = new SimpleDateFormat("yyyy-MM-dd");
                                    Date d = new Date();
                                    String strNow = String.valueOf(bartDateFormat.format(d));
                                    long l=(long)259200*(long)10000;
                                    Date d2 = new Date(System.currentTimeMillis()-l);
                                    String strMothAgo = String.valueOf(bartDateFormat.format(d2));
                                    
                                    %>                    
									<TR height="20">
										<TD class="bg_column" align="center">送货时间</TD>
										<TD align="left" class="bg_row_odd" colspan="3">
											<INPUT type="text" NAME="startdate" readonly onfocus='setday(this)' value="<%=request.getParameter("startdate")==null?strMothAgo:request.getParameter("startdate")%>"> 
											～ <INPUT type="text" NAME="enddate" readonly onfocus='setday(this)' value="<%=request.getParameter("enddate")==null?strNow:request.getParameter("enddate")%>">
										</TD>
									</TR>
									<TR height="20">
										<TD class="bg_column" align="center">对帐月份</TD>
										<TD align="left" class="bg_row_odd" colspan="3">
										 <select name="year">		
										    <option value="" >请选择年份...</option>			
						                     <%
							                  String tYear = (String)request.getParameter("year");
						 	                  String[][] tYears = GSBaseManager.getBalanceYears();
							                  if(tYears != null && tYears.length > 0 ){
								               for(int i=0; i<tYears.length; i++){
									             String[] temp = tYears[i];
									             if(tYear != null && tYear.equals(temp[0])){
						                     %>
										<option value="<%=temp[0]%>" selected>
										<%=temp[1]%></option>
						                <%				    
									                 }else{
						                %>
										<option value="<%=temp[0]%>" >
										<%=temp[1]%></option>
						                <%			
									         }
								           }
							             }
						                %>
						              </select>
						              <!--月份  -->
										 <select name="month">		
										    <option value="" >请选择月份...</option>			
						                     <%
							                  String tMonth = (String)request.getParameter("month");
						 	                  String[][] tMonths = GSBaseManager.getBalanceMonths();
							                  if(tMonths != null && tMonths.length > 0 ){
								               for(int i=0; i<tMonths.length; i++){
									             String[] temp = tMonths[i];
									             if(tMonth != null && tMonth.equals(temp[0])){
						                     %>
										<option value="<%=temp[0]%>" selected>
										<%=temp[1]%></option>
						                <%				    
									                 }else{
						                %>
										<option value="<%=temp[0]%>" >
										<%=temp[1]%></option>
						                <%			
									         }
								           }
							             }
						                %>
						              </select>
										</TD>
									</TR>
                                    <tr>
                                      <%
                                      if(tAccountlist != null) {
                                          int totalRecords = 0;
                                          if(request.getAttribute("totalRecords")!=null){
                                              totalRecords=Integer.parseInt((String)request.getAttribute("totalRecords"));
                                          }
                                          int defaultPageSize =10;
                                          if(request.getAttribute("pageSize")!=null){
                                              defaultPageSize=Integer.parseInt((String)request.getAttribute("pageSize"));
                                          }
                                          totalRecords=tAccountlist.getRecordsSize();
                                      %>          
                                      <page:pager total='<%=totalRecords%>' defaultPageSize='<%=defaultPageSize%>'>
                                       <% 
                                       tList = tAccountlist.getDisplayRecords(index.intValue(),pageSize.intValue());%>
                                      </page:pager>
                                      <%
                                      
                                      } %>
                                    </tr>
								</table>
		                    </form>
		                    <p align="center"> 
			                 <INPUT type="button" class="kuang" value="查询" onclick="return process();">&nbsp;&nbsp;
		                     <INPUT type="button" class="kuang" value="清空" onclick="return clean();">
		                    </p>
						 </td>
					</tr>
				</TBODY>
			</table>
			 <BR>				
             <%
	              if(tAccountlist != null){
             %>
             <center>
             <table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
		       <tr>
			       <td>

				<table class=bg_table id=tableId	cellspacing=1 cellpadding=2 width=100% align=center border=0>
                 <tbody> 
                                    <tr>
										<td class="bg_column" colspan="16" align="right">
										<%
										if(tAccountlist.getRecordsSize()>0){ %>
											<INPUT type="button" class="kuang" value="对帐信息下载" onclick="return download();" >
										<%} %>
										</td>
									</tr>
                                  <form name='pager' method="post">
									<tr class="bg_column" height="20">
										
										<td class="top" align="center">
											<div align="center" class="txt_content">送货单号</div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content">订货单位</div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content">供应商</div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content">集中编码</div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content">产品名称</div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content">规格</div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content">型号</div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content">品牌</div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content">生产厂商</div>
										</td>
										<!-- 
										<td class="top" align="center">
											<div align="center" class="txt_content">
												<DIV class="txt_content" align="center">订购数量</DIV>
											</div>
										</td>
										 -->
										<td class="top" align="center">
											<div align="center" class="txt_content">签收数量</div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content">价格<br>
												（元）</div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content">
												签收日期</div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content">
												签收人</div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content">详细</div>
										</td>
									</tr>
				 <%

						 if(tList != null && tList.size() > 0){
					    	for(int i=0; i<tList.size(); i++){
						       tStr = (String[])tList.get(i);
						       String tTempStr="";
						       if(i%2==0){
						     	 tTempStr="class=\"bg_row_odd\"";
						        }else {
							     tTempStr="class=\"bg_row_even\"";
							}
					%>
							<tr <%=tTempStr%> height=20>
										
										<td class="top" align="middle">
											<div align="center" class="txt_content">
											<%=tStr[0]%>
											</div>
										</td>
										<td class="top" align="middle">
											<div align="center" class="txt_content">
											<%=tStr[1]%>
											</div>
										</td>
										<td class="top" align="middle">
											<div align="center" class="txt_content">
											<%=tStr[2]%>	
											</div>
										</td>
										<td class="top" align="middle">
											<div align="center" class="txt_content">
											<%=tStr[3]%>
											</div>
										</td>
										<td class="top" align="middle">
											<a href="<%= response.encodeURL(request.getContextPath() + "/A100404.do") %>?concentricityId=<%=tStr[3]%>" target="_blank">
									    	<%=tStr[4]%>
											</a>
										</td>
										<td class="top" align="middle">
											<div align="center" class="txt_content">
											<%=tStr[5]%>
											</div>
										</td>
										<td class="top" align="middle">
											<div align="center" class="txt_content">
											<%=tStr[6]%>
											</div>
										</td>
										<td class="top" align="middle">
											<div align="center" class="txt_content">
											<%=tStr[7]%>
											</div>
										</td>
										<td class="top" align="middle">
											<div align="center" class="txt_content">
											
											<%=tStr[8]%>
											</div>
										</td>
                                        <!-- <td class="top" align="middle">
											<div align="center" class="txt_content">
											<%=tStr[9]%> <%=tStr[16]%>
											</div>
										</td>
										-->
										<td class="top" align="middle">
											<div align="center" class="txt_content">
											<%=tStr[10]%> <%=tStr[16]%>
											</div>
										</td>
										<td class="top" align="middle">
											<div align="center" class="txt_content">
											<%=tStr[11]%>
											</div>
										</td>
										<td class="top" align="middle">
											<div align="center" class="txt_content">
											<%=tStr[12]%>
											</div>
										</td>
										<td class="top" align="middle">
											<div align="center" class="txt_content">
											<%=tStr[13]%>
											</div>
										</td>
										<td class="top" align="middle">
										<a href="<%= response.encodeURL(request.getContextPath() + "/A100403.do") %>?orderId=<%=tStr[14]%>&orderDetailId=<%=tStr[15]%>" target="_blank">
									     详细
										</a>	
										</td>
									</tr>
									
				    <%
						}
					%>
									 <tr class="bg_column" height=20>
						                <td width="960" height="16" colspan="16" align="right">
									         <!--导航条-->
						    		         <page:navigator type='text' queryForm='accountform'/>
						                </td>
						            </tr>					
				   <%
						}else{
				   %>
							<font color="red">没有符合条件的本月对帐信息</font>
				   <%
						}
				   %>
                          </form>
				           </tbody>
						</table>

							</td>
		                  </tr>
                   	</table>
	             </center>
			    	 
			<%} %>
	</body>
</html>
